package com.logistics.utils.response;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

public class ResponseUtil {

    public static ResponseEntity success(){
        return ResponseEntity.ok(new Response(ResponseStatus.SUCCESS.getCode(),
                ResponseStatus.SUCCESS.getMessage()));
    }

    public static ResponseEntity success(Object data){
        return ResponseEntity.ok(new Response(ResponseStatus.SUCCESS.getCode(),
                ResponseStatus.SUCCESS.getMessage(), data));
    }

    public static ResponseEntity error(){
        return new ResponseEntity(new Response(ResponseStatus.ERROR.getCode(),
                ResponseStatus.ERROR.getMessage()), HttpStatus.BAD_REQUEST);
    }

    public static ResponseEntity checkError(String msg){
        return ResponseEntity.ok(new Response(ResponseStatus.ERROR.getCode(), msg));
    }

    public static ResponseEntity authorityError(){
        return new ResponseEntity(new Response(ResponseStatus.AUTHORITY.getCode(),
                ResponseStatus.AUTHORITY.getMessage()), HttpStatus.OK);
    }

    public static ResponseEntity renewal(String token){
        return new ResponseEntity(new Response(ResponseStatus.RENEWAL.getCode(),
                ResponseStatus.RENEWAL.getMessage(), token), HttpStatus.OK);
    }
}
